package com.lixw.aiassistant.config;

import com.alibaba.cloud.ai.memory.redis.RedisChatMemoryRepository;
import com.lixw.aiassistant.tool.OrderFunctionTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AgentConfig {

    private static final String QWEN_MODEL = "deepseek-v3";
    @Autowired
    private OrderFunctionTool orderFunctionTool;
    @Bean
    public ChatMemory chatMemory(RedisChatMemoryRepository redisChatMemoryRepository) {
        //窗口记忆10条
        return MessageWindowChatMemory.builder()
                .chatMemoryRepository(redisChatMemoryRepository)
                .maxMessages(10).build();
    }

    @Bean
    public ChatClient chatClient(ChatModel chatModel) {
        return ChatClient.builder(chatModel)
                //.defaultOptions(ChatOptions.builder().model(QWEN_MODEL).build())
                .build();
    }

}